package run;

import interpreter.AspectRecognizer;
import interpreter.PropertyRecognizer;

import java.io.FileReader;
import java.io.IOException;
import java.io.PushbackReader;

import lexer.Lexer;
import lexer.LexerException;
import node.Start;
import parser.Parser;
import parser.ParserException;

public class Execute {
	
	public static void main(String[] args) throws ParserException, LexerException, IOException {
		if (args.length > 0) { 
				/* Form the AST */ 
				Lexer lexer = new Lexer (new PushbackReader(new FileReader(args[0]), 1024)); 
				Parser parser = new Parser(lexer); 
				Start ast = parser.parse(); 

				/* Getting Interpreter elements. */ 
				PropertyRecognizer interpProperty = new PropertyRecognizer(); 
				ast.apply(interpProperty); 
				
				AspectRecognizer aspProperty = new AspectRecognizer(); 
				ast.apply(aspProperty); 
		} else { 
			System.err.println("No input file found."); 
			System.exit(1); 
		} 
	} 
}
